package com.ly.thread;
import	java.util.concurrent.CompletableFuture;

import java.util.concurrent.ExecutionException;

public class CompletableFutureDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Integer> completableFuture = CompletableFuture.supplyAsync(() -> {
            System.out.println(Thread.currentThread().getName());
            int a = 1/0;
            return 1024;
        });

        completableFuture.whenComplete((t,u) -> {
            System.out.println(t);
            System.out.println(u);
        }).exceptionally(f -> {
            System.out.println(f);
            return 201;
        }).get();


    }
}
